<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('漫画评论列表')" />
    <!--select 下拉框-->
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>漫画id：</label>
                               <!-- <input type="text" name="nameId"/>-->
                                <select name="nameId" class="form-control m-b" th:with="type=${MhNameDataAll}">
                                    <option value=""></option>
                                    <option th:each="map : ${type}" th:text="${map.value}" th:value="${map.key}"></option>
                                </select>
                            </li>
                            <!--<li>
                                <label>上级id 0为顶级：</label>
                                <input type="text" name="superior"/>
                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="manhua:comment:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="manhua:comment:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="manhua:comment:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="manhua:comment:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <!--select 下拉框-->
     <th:block th:include="include :: select2-js"/>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('manhua:comment:edit')}]];
        var removeFlag = [[${@permission.hasPermi('manhua:comment:remove')}]];
        var prefix = ctx + "manhua/comment";
        let MhNameDataAll = [[${MhNameDataAll}]];
        $(function() {
            var options = {
                url: prefix + "/list",
                queryParams: {nameId:[[${nameId}]],superior:0},
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "漫画评论",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                detailView: true,
                onExpandRow : function(index, row, $detail) {
                    initChildTable(index, row, $detail);
                },
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'nameId',
                    title: '漫画id',
                    formatter: function (value, row, index) {
                        return $.common.reale({value:MhNameDataAll[value], numder: 2});
                    }
                },
                {
                    field: 'superior',
                    title: '级别',
                    formatter: function (value, row, index) {
                        return $.common.reale({value:"一级", numder: 1});
                    }
                },
                {
                    field: 'remark',
                    title: '评论',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value,null,"open");
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        initChildTable = function(index, row, $detail) {
            var childTable = $detail.html('<table style="table-layout:fixed"></table>').find('table');
            $(childTable).bootstrapTable({
                url: prefix + "/list",
                queryParams: {nameId:[[${nameId}]],superior:row.id},
                method: 'post',
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                sidePagination: "server",
                contentType: "application/x-www-form-urlencoded",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                detailView: true,
                onExpandRow : function(index, row, $detail) {
                    initChildTable3(index, row, $detail);
                },
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'id',
                        title: 'id',
                        visible: false
                    },
                    {
                        field: 'nameId',
                        title: '漫画id',
                        formatter: function (value, row, index) {
                            return $.common.reale({value:MhNameDataAll[value], numder: 3});
                        }
                    },
                    {
                        field: 'superior',
                        title: '级别',
                        formatter: function (value, row, index) {
                            return $.common.reale({value:"二级", numder: 2});
                        }
                    },
                    {
                        field: 'remark',
                        title: '评论',
                        formatter: function (value, row, index) {
                            return $.table.tooltip(value,null,"open");
                        }
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                        }
                    }]
            });
        };

        initChildTable3 = function(index, row, $detail) {
            var childTable = $detail.html('<table style="table-layout:fixed"></table>').find('table');
            $(childTable).bootstrapTable({
                url: prefix + "/list",
                queryParams: {nameId:[[${nameId}]],superior:row.id},
                method: 'post',
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                sidePagination: "server",
                contentType: "application/x-www-form-urlencoded",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                detailView: true,
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'id',
                        title: 'id',
                        visible: false
                    },
                    {
                        field: 'nameId',
                        title: '漫画id',
                        formatter: function (value, row, index) {
                            return $.common.reale({value:MhNameDataAll[value], numder: 1});
                        }
                    },
                    {
                        field: 'superior',
                        title: '级别',
                        formatter: function (value, row, index) {
                            return $.common.reale({value:"三级", numder: 3});
                        }
                    },
                    {
                        field: 'remark',
                        title: '评论',
                        formatter: function (value, row, index) {
                            return $.table.tooltip(value,null,"open");
                        }
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                        }
                    }]
            });
        };
    </script>
</body>
</html>